const express = require("express")
const cors = require("cors")
// const mysql = require("./db")
const {graphqlHTTP} = require('express-graphql');
const GraphQLSchema = require('./schema/default.js');

const app = express()

// 处理跨域请求
app.use(cors())
// 处理请求
app.use(express.json());//express.json=bodyParser.json
app.use(express.urlencoded({ extended: true }));

// 配置express中间件
app.use('/graphql', graphqlHTTP({
    schema: GraphQLSchema, // MyGraphQLSchema待定
    graphiql: true, // 开发环境打开调试面板，生产的时候可以关闭
  }),
);

app.listen(8000, () => {
  console.log("服务已启动: localhost:3000");
})
